// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

//	x=document.getElementById("demo");  // 找到元素
//	x.innerHTML="Hello JavaScript!";    // 改变内容
function click(e) {
//	alert("<p>This is a paragraph.</p>");
	chrome.tabs.executeScript(null, 
		{code:"document.body.style.backgroundColor='" + e.target.id + "'"});
//	{code:"document.body.style.backgroundColor='red'"});
//	{code:"document.write('"<p>This is a paragraph.</p>"')"});
//	{code:"alert('"<p>This is a paragraph.</p>"')"});
//	{code:"document.getElementById('demo')"});  // 找到元素
//  chrome.tabs.executeScript(null, 
//	{code:"x.innerHTML='"Hello JavaScript!"'"});    // 改变内容
//	x.innerHTML="Hello JavaScript!";    // 改变内容


  window.close();
}

document.addEventListener('DOMContentLoaded', function () {
  var divs = document.querySelectorAll('div');
  for (var i = 0; i < divs.length; i++) {
    divs[i].addEventListener('click', click);
  }
});
//chrome.browserAction.setBadgeText({text: ‘3’});
document.write("<p>This is a paragraph." + "aaa</p>");
